#ifndef C3DWIDGET_H
#define C3DWIDGET_H


#include <QWidget>
#include <QtDataVisualization>
#include <QtDataVisualization/Q3DScatter>
#include <QtDataVisualization/QScatter3DSeries>
#include <QtDataVisualization/QScatterDataProxy>
#include <QtDataVisualization/Q3DTheme>
#include <QVector3D>
#include <QCamera>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include "vcomstruct.h"


using namespace QtDataVisualization;  //设置命名空间

class c3DWidget : public QWidget
{
    Q_OBJECT
public:
    explicit c3DWidget(QWidget *parent = nullptr);
    ~c3DWidget(void);

    // 创建 3D 绘图对象
    Q3DScatter *scatter = nullptr;

    // 创建相机
    Q3DCamera *camera = nullptr;

    // 创建一个 3D 视图并设置为线条模式
    QWidget *container = nullptr;

    // 输入点组
    QVector<QVector3D> keyPoints;
    // 平滑点数据组
    QVector<QVector3D> smoothCurvePoints;
    // 井平滑点数据组
    QVector<QVector3D> originCurvePoints;
    QVector<QVector3D> newCurvePoints;

    // 创建曲线系列
    QScatter3DSeries* series = nullptr;
    QScatter3DSeries* originseries = nullptr;
    QScatter3DSeries* newseries = nullptr;

    /* Catmull-Rom 样条插值：计算平滑曲线上的点 */
    QVector<QVector3D> interpolateCatmullRom(const QVector<QVector3D>& points, int numInterpolatedPoints);
    /* 工具函数：将 QVector<QVector3D> 转为 QScatterDataArray */
    QScatterDataArray* generateSmoothCurveData(const QVector<QVector3D>& points);
    /* 计算正钻井相关点位数据 */
    QVector3D calculateNewPoint(const QVector3D &center, double angle, double distance);


    /* 绘制原井轨迹 */
    void vDrawOriginWell(QList<RelatWellData> pdata);
    /* 绘制新井轨迹 */
    void vDrawNewWell(QList<RelatWellData> pdata);

    void rotateLeft() {
         qDebug() << "rotateLeft";
         camera->setXRotation(30);
         camera->setCameraPosition(1,0,10);
//        scatter->
//        // 向左旋转
//        scatter->setRotation(scatter->rotationX(), scatter->rotationY() - 5.0f);
    }

    void rotateRight() {
        // 向右旋转
//        scatter->setRotation(scatter->rotationX(), scatter->rotationY() + 5.0f);
    }

signals:




};

#endif // C3DWIDGET_H
